Listing 2. Listing of CanDoTextReader.z Created by CD_ADE



Deck "CanDoTextReader"
  Card "TextReader"
    BeforeAttachment
      MakeDocument "TextDoc"
    EndScript
    Window "UserWindow"
      Definition
        Origin 108,44
        Size 320,200
        Title "CanDo Text File Reader"
        NumberOfColors 4,69632
        DefaultColors 0,1,0
        WindowObjects CLOSEBUTTON DEPTHBUTTONS DRAGBAR SIZEBUTTON 
        WindowFlags ACTIVATE TOFRONT WORKBENCH 
        VisualEffects NONE ,WAIT 
      EndScript
      OnCloseButton
        Quit
      EndScript
      OnResized
        MoveObject "SelectFile",(WindowWidth%2)-95,WindowHeight-20
      EndScript
    EndObj
    Memo "FileMemo"
      Definition
        Origin 11,16
        Size 285,156
        Font "topaz",8
        Style PLAIN ,2,3
        TextColors 1,0,JAM2 
        Border DOUBLEBEVEL ,2,1
        MemoDocument "TextDoc"
        ScrollBars RIGHT 
        InputStyle NORMAL 
      EndScript
    EndObj
    TextButton "SelectFile"
      Definition
        Origin 65,180
        Font "topaz",11
        Style BOLD SHADOW ,2,3
        TextColors 1,0,JAM1 
        Text " Select File to View "
        Border BEVEL ,2,1
        Highlight COMPLEMENT 
        ButtonFlags NONE 
      EndScript
      OnRelease
        Let Heading="Select a text file to view"
        Let FNNew=AskForFileName(FN,Heading,WindowX+100,WindowY+100)
        If FNNew<>""
          Let FN=FNNew
          OpenFile FN,"FileBuf",READONLY ,OLDFILE 
          GetFileInfo FN,FNSize
          FileReadChars "FileBuf",TextVar,FNSize
          Close "FileBuf"
          Clear DOCUMENT 
          Type TextVar
          MoveCursorTo STARTOF DOCUMENT 
        EndIf
      EndScript
    EndObj
  EndObj
EndObj
